package com.wellwan.cloud.user.service;

import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

import java.util.Objects;

/**
 * Copyright (C),微动天下
 * FileName: CustomUserDetailsService
 * Author:   maokai
 * Date:     2020/2/24 16:24
 * Description:
 */
@Service
public class CustomUserDetailsService implements UserDetailsService {
    @Override
    public UserDetails loadUserByUsername(String userName) throws UsernameNotFoundException {
        if(Objects.equals("user",userName)){
            return new SecurityUser("user", "password1", "user-role");
        } else if (Objects.equals("admin", userName)) {
            return new SecurityUser("admin", "password2", "admin-role");
        } else {
            return null;
        }
    }
}
